﻿using OpenCvSharp.ImgHash;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Dynamic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TemplateMatch
{
    public class Template
    {
        public string Name;
        public TemplateStatus Status;
        private int index;

        Image TemplateImage;

        public Template(int Index)
        {
            this.Status = TemplateStatus.NotSaved;
            this.index = Index;
        }

        public int GetIndex()
        {
            return this.index;
        }

        public void SetImage(Image img)
        {
            this.TemplateImage = img;
        }

        public void Save(string folderName)
        {
            string filename = folderName + "\\" + this.Name + ".png";
            this.TemplateImage.Save(filename, System.Drawing.Imaging.ImageFormat.Png);
        }

        public void Dispose()
        {
            this.TemplateImage.Dispose();
        }

        public Image GetImage()
        {
            return this.TemplateImage;
        }
    }

    public enum TemplateStatus
    {
        NotSaved,
        Saved,
        Skipped,
    }

    public class MatchPoint
    {
        public OpenCvSharp.Point TopLeftPoint;
        public double matchValue;
        public int Status;
    }

    public class MatchConfig
    {
        //Match setting
        public double Thresh;
        public double xScaleFrom, xScaleTo, xStep, yScaleFrom, yScaleTo, yStep;

        //Pre-treatment setting
        public int BlurKernelSize;
        public int MorphShapeSize;
        public bool DoCanny;
        public bool DoTopHat;
        public bool Reform;

        public MatchConfig()
        {
            Thresh = 0.75;
            Reform = false;
            xScaleFrom = 1.0;
            xScaleTo = 1.0;
            xStep = 0;
            yScaleFrom = 1.0;
            yScaleTo = 1.0;
            xStep = 0;

            BlurKernelSize = 3;
            MorphShapeSize = 5;
            DoCanny = false;
            DoCanny = true;
        }
    }
}
